using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.Xml;

namespace RaidLog
{
    public static class Util
    {
        public static TType ReadData<TType>(string file)
        {
            using (XmlTextReader g = new XmlTextReader(file))
            {
                XmlSerializerFactory a = new XmlSerializerFactory();
                XmlSerializer b = a.CreateSerializer(typeof(TType));
                return (TType) b.Deserialize(g);
            }
        }

        public static void WriteData<TType>(TType data, string file)
        {
            using (XmlTextWriter g = new XmlTextWriter(file, Encoding.Default))
            {
                XmlSerializerFactory a = new XmlSerializerFactory();
                XmlSerializer b = a.CreateSerializer(typeof(TType));
                b.Serialize(g, data);
            }
        }
    }
}